package com.yaolonga.dc.core.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author yaolong
 * @since 1.1.4
 */
@AllArgsConstructor
@NoArgsConstructor
@Data
public class Sort {
    private String field;
    private String value;

    public static final String ASC = "asc";
    public static final String DESC = "desc";


    public static Sort of(String field, String value) {
        return new Sort(field, value);
    }

    public static Sort of(String field) {
        return new Sort(field, ASC);
    }

    public static Sort ofDesc(String field) {
        return new Sort(field, DESC);
    }

    public static Sort ofAsc(String field) {
        return new Sort(field, ASC);
    }

    public Sort desc(String field) {
        this.value = DESC;
        this.field = field;
        return this;
    }

    public Sort asc(String field) {
        this.field = field;
        this.value = ASC;
        return this;
    }

}
